package com.cloudcentral.controller;

import com.cloudcentral.exception.FailureException;
import com.cloudcentral.service.DisabledFrequencyService;
import com.cloudcentral.util.Result;
import com.cloudcentral.entity.DisabledFrequency;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 禁用频率表 前端控制器
 * </p>
 *
 * @author Administrator
 * @since 2023-11-23
 */
@Slf4j
@RestController
@RequestMapping("/disabled-frequency")
@Tag(name = "禁用频率")
public class DisabledFrequencyController extends BaseController {
  private final DisabledFrequencyService disabledFrequencyService;

  @Autowired
  public DisabledFrequencyController(DisabledFrequencyService disabledFrequencyService) {
    this.disabledFrequencyService = disabledFrequencyService;
  }

  @PostMapping("/submit")
  @Operation(summary = "提交")
  public Result<Boolean> submit(DisabledFrequency disabledFrequency) throws FailureException {
    return Result.ok(disabledFrequencyService.submit(disabledFrequency));
  }

  @DeleteMapping("/delete")
  @Operation(summary = "删除")
  public Result<Boolean> delete(Long id) {
    return Result.ok(disabledFrequencyService.delete(id));
  }

  @GetMapping("/listAll")
  @Operation(summary = "集合")
  public Result<List<DisabledFrequency>> listAll() {
    return Result.ok(disabledFrequencyService.list());
  }
}
